<template>
  <div class="page">
    <el-pagination
      background
      align="right"
      :current-page="page.currentPage"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="page.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    ></el-pagination>
  </div>
</template>

<script>
  export default {
    props: {
      total: {
        type: Number,
        default: 0,
        require: true,
      },
    },
    data() {
      return {
        // 页码参数
        page: {
          currentPage: 1, // 页码
          pageSize: 10, // 每页展示条数
        },
      };
    },
    methods: {
      handleSizeChange(val) {
        this.page.pageSize = val;
        // eslint-disable-next-line vue/custom-event-name-casing
        this.$emit("pageChange", this.page);
      },
      handleCurrentChange(val) {
        this.page.currentPage = val;
        // eslint-disable-next-line vue/custom-event-name-casing
        this.$emit("pageChange", this.page);
      },
    },
  };
</script>
